package com.yanggu.scala.chapater04

object WhileDemo02 {

  def main(args: Array[String]): Unit = {
    //1. 计算1-100的和
    var i = 1
    var sum = 0
    while (i < 101) {
      sum += i
      i += 1
    }
    println(sum)

    //2. 统计1-200之间能被5整除但不能被3整除的个数
    var num = 0
    for (i <- 1 to 200 if i % 5 == 0 && i % 3 != 0) {
      num += 1
    }
    println(num)
  }

}
